package com.ruoyi.bizsys.service.impl;

import java.util.List;
import java.util.Arrays;
                                                                                                                                                                    import com.ruoyi.common.utils.DateUtils;
            import org.springframework.stereotype.Service;
    import com.ruoyi.bizsys.mapper.RuleHitMapper;
import com.ruoyi.bizsys.domain.RuleHit;
import com.ruoyi.bizsys.service.IRuleHitService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;


/**
 * 策略命中记录Service业务层处理
 *
 * @author african-loan
 * @date 2021-10-28
 */
@Service
public class RuleHitServiceImpl extends ServiceImpl<RuleHitMapper,RuleHit> implements IRuleHitService {

    /**
     * 查询策略命中记录
     *
     * @param id 策略命中记录ID
     * @return 策略命中记录
     */
    @Override
    public RuleHit selectRuleHitById(Long id) {
        return this.getById(id);
    }

    /**
     * 查询策略命中记录列表
     *
     * @param ruleHit 策略命中记录
     * @return 策略命中记录
     */
    @Override
    public List<RuleHit> selectRuleHitList(RuleHit ruleHit) {
        return this.list(new QueryWrapper<>(ruleHit).last("order by id desc"));
    }

    /**
     * 新增策略命中记录
     *
     * @param ruleHit 策略命中记录
     * @return 结果
     */
            @Override
    public int insertRuleHit(RuleHit ruleHit) {
                                                                                                                                                                                                                                                                                    ruleHit.setCreateTime(DateUtils.getNowDate());
                                                return baseMapper.insert(ruleHit);
    }

    /**
     * 修改策略命中记录
     *
     * @param ruleHit 策略命中记录
     * @return 结果
     */
            @Override
    public int updateRuleHit(RuleHit ruleHit) {
                                                                                                                                                                                                                                                                                                        ruleHit.setUpdateTime(DateUtils.getNowDate());
                            return baseMapper.updateById(ruleHit);
    }

    /**
     * 批量删除策略命中记录
     *
     * @param ids 需要删除的策略命中记录ID
     * @return 结果
     */
            @Override
    public int deleteRuleHitByIds(Long[] ids) {
        return baseMapper.deleteBatchIds(Arrays.asList(ids));
    }

    /**
     * 删除策略命中记录信息
     *
     * @param id 策略命中记录ID
     * @return 结果
     */
    @Override
    public int deleteRuleHitById(Long id) {
        return baseMapper.deleteById(id);
    }

}
